//
//  VisitorView.swift
//  ZJWeiBo
//
//  Created by 张建 on 2018/3/20.
//  Copyright © 2018年 micheal. All rights reserved.
//

import UIKit
import SnapKit

class VisitorView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        // 添加控件
        addSubview(iconView)
        addSubview(maskBgView)
        addSubview(homeIcon)
        addSubview(msgLabel)
        addSubview(registerBtn)
        addSubview(loginBtn)
        self.backgroundColor = UIColor.blue
    }
    
    // 布局
    override func layoutSubviews() {
        
        // 转盘
        iconView.snp.makeConstraints { (make) in
            make.center.equalTo(self)
            make.width.height.equalTo(200)
        }
        // homeIcon
        homeIcon.snp.makeConstraints { (make) in
            make.center.equalTo(self)
            make.width.height.equalTo(100)
        }
        // 蒙层
        maskBgView.snp.makeConstraints { (make) in
            make.center.equalTo(self)
            make.width.equalTo(self)
            make.height.equalTo(self)
        }
        // 消息label
        msgLabel.snp.makeConstraints { (make) in
            make.top.equalTo(iconView.snp.bottom).offset(10)
            make.centerX.equalTo(self)
            make.width.equalTo(iconView)
            make.height.equalTo(80)
        }
        // 登陆
        loginBtn.snp.makeConstraints { (make) in
            
            make.left.equalTo(msgLabel.snp.left)
            make.top.equalTo(msgLabel.snp.bottom).offset(5)
            make.width.equalTo(80)
            make.height.equalTo(35)
        }
        // 注册
        registerBtn.snp.makeConstraints { (make) in
            make.right.equalTo(msgLabel.snp.right)
            make.top.equalTo(msgLabel.snp.bottom).offset(5)
            make.width.equalTo(80)
            make.height.equalTo(35)
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - 懒加载控件
    
    /// 转盘
    private lazy var iconView: UIImageView = {
        
        let iv = UIImageView(image:#imageLiteral(resourceName: "visitordiscover_feed_image_smallicon") )
        iv.sizeToFit()
        return iv
    }()
    
    /// homeIcon
    private lazy var homeIcon: UIImageView = {
       
        let hi = UIImageView(image: #imageLiteral(resourceName: "visitordiscover_feed_image_house"))
        hi.sizeToFit()
        return hi
    }()
    
    /// 蒙层
    private lazy var maskBgView: UIImageView = {
        
        let hi = UIImageView(image: #imageLiteral(resourceName: "visitordiscover_feed_mask_smallicon"))
        hi.sizeToFit()
        return hi
    }()
    
    /// 消息label
    private lazy var msgLabel: UILabel = {
       
        let messageLabel = UILabel()
        messageLabel.text = "这里是微博首页，大伙儿可以常来逛逛，感受下微博的魅力～"
        messageLabel.numberOfLines = 0
        return messageLabel
    }()
    
    /// 注册
    private lazy var registerBtn: UIButton = {
        
        let regisBtn = UIButton(type: UIButtonType.system)
        regisBtn.setTitleColor(UIColor.lightGray, for: UIControlState.normal)
        regisBtn.backgroundColor = UIColor.white
        regisBtn.setTitle("登陆", for: UIControlState.normal)
        return regisBtn
    }()
    
    /// 登录
    private lazy var loginBtn: UIButton = {
        let loginBtn = UIButton(type: UIButtonType.system)
        loginBtn.setTitleColor(UIColor.lightGray, for: UIControlState.normal)
        loginBtn.backgroundColor = UIColor.white
        loginBtn.setTitle("注册", for: UIControlState.normal)
        return loginBtn
    }()
    
    
    
}
